package com.matthew.luckyone.controller;

import com.matthew.luckyone.service.ClazzService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RequestMapping("/clazz")
@RestController
public class ClazzController {

    @Resource
    private ClazzService clazzService;


    /**
     * 根据班级名称添加班级
     */
    @GetMapping("/addClazz")
    public boolean addClazz(@RequestParam("clazzName") String clazzName) {
        return clazzService.addClazz(clazzName);
    }

    /**
     * 根据班级名称删除班级
     *
     * @param clazzName
     * @return
     */
    @GetMapping("/deleteClazz")
    public boolean deleteClazz(@RequestParam("clazzName") String clazzName) {
        return clazzService.deleteClazz(clazzName);
    }

    /**
     * 根据班级名称抽取幸运儿
     *
     * @param clazzName
     * @return
     */

    @GetMapping("/luckyOne")
    public String luckyOne(@RequestParam("clazzName") String clazzName) {
        return clazzService.luckyOne(clazzName);
    }

    /**
     * 根据班级名称获取学生集合
     *
     * @param clazzName
     * @return
     */
    @GetMapping("/studentList")
    public List<String> list(@RequestParam("clazzName") String clazzName) {
        return clazzService.studentList(clazzName);
    }

    /**
     * 目前数据状态
     */
    @GetMapping("/clazzMap")
    public Map<String, ArrayList<String>> clazzMap() {
        return clazzService.clazzMap();
    }


    /**
     * 根据班级名称和学生名称 添加学生
     */
    @GetMapping("/addStudent")
    public boolean addStudent(@RequestParam("clazzName") String clazzName, @RequestParam("studentName") String studentName) {
        return clazzService.addStudent(clazzName, studentName);
    }

    /**
     * 根据班级名称和学生名称 删除学生
     *
     * @param clazzName
     * @param studentName
     * @return
     */
    @GetMapping("/deleteStudent")
    public boolean deleteStudent(@RequestParam("clazzName") String clazzName, @RequestParam("studentName") String studentName) {
        return clazzService.deleteStudent(clazzName, studentName);
    }



}
